//
// Created by 11067 on 2023/3/12.
//
#include <gtest/gtest.h>
#include <gmock/gmock.h>
#include "../src/api.h"

TEST(APIChainCnt, General) {
    const char *words[]{"a", "aXb", "aXc", "bxc", "dxe", "exf", "fxg", "exg"};
    size_t len{8};
    char **result{alloc_result()};
    int r = gen_chains_all(const_cast<char **>(words), static_cast<int>(len), result);
    ASSERT_EQ(r,8);
    std::vector<std::string> result_vec{};
    for (int i = 0; i < r; ++i) {
        result_vec.emplace_back(result[i]);
    }
    std::vector<std::string>ans {
            "a axb ",
            "a axc ",
            "axb bxc ",
            "dxe exf ",
            "exf fxg ",
            "dxe exg ",
            "a axb bxc ",
            "dxe exf fxg "
    };
    ASSERT_THAT(result_vec, testing::UnorderedElementsAreArray(ans));
}

